<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<script>
let a = [1,2,3,4,5,6];  // Array

Array.prototype.show = function(){
    for(let i =0;i< this.length;i++){
        //this[i]*=2;
        console.log( this[i]);
    }
}

//var ret = a.filter( v=> v<=3 );

Array.prototype.guolv = function(fn) {
    if(typeof fn !== 'function') return
    let res = []
    for(let i = 0 ; i < this.length ; i++) {
        if(fn(this[i])){
            res.push(this[i])
        }
    }
    return res
}

let ret = a.guolv( v=> v>3 )

ret.show(); // 遍历打印数组每个元素



</script>    
</body>
</html>